//
//  ReceiveCell.m
//  PigMarket
//
//  Created by mac on 2019/5/10.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "ReceiveCell.h"
#import "ReceivePigInfoView.h"

@interface ReceiveCell ()
/**
 pigInfoView
 */
@property (nonatomic , strong) ReceivePigInfoView *pigInfoView;
@end
@implementation ReceiveCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}
- (void)initView {
    [self.contentView addSubview:self.pigInfoView];
}
- (void)initLayout {
    [self.pigInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(-15);
    }];
}
- (void)configCellWithModel:(ReceivePig *)model{
    [self.pigInfoView.headImg sd_setImageWithURL:[NSURL URLWithString:model.headImg] placeholderImage:[UIImage imageNamed:@"placeholder_middle"]];
    self.pigInfoView.pigInfoTitle.text = model.varietiesName;
    self.pigInfoView.pigNum.text = [NSString stringWithFormat:@"编号%@",model.pigNum];
    self.pigInfoView.birthdayDetailLab.text = model.birthDate;
    self.pigInfoView.adoptedDateDetailLab.text = model.adoptDate;
    self.pigInfoView.currentDaysDetailLab.text = [NSString stringWithFormat:@"%@日",model.dayAge];
    self.pigInfoView.weightDetailLab.text = [NSString stringWithFormat:@"%@kg(%@)",model.weight,model.weightDate];
    self.pigInfoView.dateDetailLab.text = [NSString stringWithFormat:@"距离%@还剩%@天",model.expectOutDate,model.expectOutDays];
    self.pigInfoView.arrearageDetailMoney.text = [NSString stringWithFormat:@"￥%@",model.arrears];
    self.pigInfoView.transferDetailMoney.text = [NSString stringWithFormat:@"￥%@",model.money];
    if (model.isSelect) {
        self.pigInfoView.layer.borderColor = [UIColor primaryColor].CGColor;
        self.pigInfoView.layer.borderWidth = 1;
    } else {
        self.pigInfoView.layer.borderColor = [UIColor clearColor].CGColor;
        self.pigInfoView.layer.borderWidth = 1;
    }
    
}
- (ReceivePigInfoView *)pigInfoView {
    if (!_pigInfoView) {
        _pigInfoView = [[ReceivePigInfoView alloc] init];
        _pigInfoView.backgroundColor = [UIColor whiteColor];
        _pigInfoView.layer.cornerRadius = 8;
        _pigInfoView.layer.shadowColor = [UIColor colorWithRed:217/255.0 green:226/255.0 blue:233/255.0 alpha:0.5].CGColor;
        _pigInfoView.layer.shadowOffset = CGSizeMake(0,5);
        _pigInfoView.layer.shadowOpacity = 1;
        _pigInfoView.layer.shadowRadius = 12;
    }
    return _pigInfoView;
}
@end
